(function($) {

	$.fn.hslideShow = function() {
		$container = $(this);
		$progress_bar = $(this).find('#progress');
		$wrapper = $(this).find('#slider-wrapper');
		$index_list = $(this).find('#index-list');
		$thumbs = $index_list.children();
		var stopBar = 0;
		$thumbs.each(function(index){
		
			$(this).click(function() {
				thumbHighlight(index);
				stopBar = 1;
				slide(index);
				$progress_bar.stop();
				$progress_bar.css({width: '0'});
			
			});
		
		});
		
		
		
		
		$slides = $wrapper.children();
		var total_elem = $slides.length;
		var w_w = $(window).width();
		var current = 0;
		init();
		progressBar();
		
		
		
		function init() {
			var wrapper_width = total_elem * w_w;
			$wrapper.width(wrapper_width + 'px');
			$slides.width(w_w +'px');
			
		
		}
		
		function progressBar() {
			if(stopBar != 1) {
				thumbHighlight(current);
				$progress_bar.animate({width:'100%'}, 15000, function() {
					$(this).css({width:'0'});
					
					nextSlide();
					progressBar();
				
				});
			}
			
			
		
		
		}
		
		
		function nextSlide() {

			current = current >= total_elem - 1 ? 0: current+1;
			slide(current);
		
		}
		
		function thumbHighlight(index) {
			$thumbs.removeClass('active');
			$thumbs.eq(index).addClass('active');
		
		}
		
		function slide(index) {
			var slideTo = parseInt(-w_w * index);
			
			$wrapper.stop().animate({
						left	: slideTo + 'px'
					},1000, 'jswing');
		
		
		
		}
		
		
		
		
		
	
	
	}
	
	
	









})(jQuery);
